|
A variable-length quantity (VLQ) is a universal code that uses an arbitrary number of binary octets (eight-bit bytes) to represent an arbitrarily large integer. It was defined for use in the standard MIDI file format〔(MIDI File Format: Variable Quantities )〕 to save additional space for a resource constrained system, and is also used in the later Extensible Music Format (XMF). A VLQ is essentially a base-128 representation of an unsigned integer with the addition of the eighth bit to mark continuation of bytes. See the example below. Base-128 is also used in ASN.1 BER encoding to encode tag numbers and Object Identifiers.〔http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf〕 It is also used in the WAP environment, where it is called variable length unsigned integer or uintvar. The DWARF debugging format〔(DWARF Standard )〕 defines a variant called LEB128 (or ULEB128 for unsigned numbers), where the least significant group of 7 bits are encoded in the first byte and the most significant bits are in the last byte (so effectively it is the little-endian analog of a variable-length quantity). Google's protocol buffers use a similar format to have compact representation of integer values,〔(Google Protocol Buffers )〕 as does Oracle's Portable Object Format (POF)〔(Oracle Portable Object Format (POF) )〕 and the Microsoft .NET Framework's "7-bit encoded int" in the BinaryReader and BinaryWriter classes.〔(System.IO.BinaryWriter.Write7BitEncodedInt(int) method ) and (System.IO.BinaryReader.Read7BitEncodedInt() method )〕 It's also used extensively in web browsers for source mapping - which contain a lot of integer line & column number mappings - to keep the size of the map to a minimum.〔(Introduction to javascript source maps )〕 ==General structure== The encoding assumes an octet (an eight-bit byte) where the most significant bit (MSB), also commonly known as the sign bit, is reserved to indicate whether another VLQ octet follows. If A is 0, then this is the last VLQ octet of the integer. If A is 1, then another VLQ octet follows. B is a 7-bit number (0x7F ) and n is the position of the VLQ octet where B0 is the least significant. The VLQ octets are arranged most significant first in a stream. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Variable-length quantity」の詳細全文を読む スポンサード リンク
|